﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Scrum.Net.Classes;
using Scrum.Net.Interfaces;

namespace Scrum.NetTests
{
    [TestClass]
    public class SprintTest
    {
        private readonly IProject _prj;
        private readonly ISprint _sprint;

        public SprintTest()
        {
            _prj = new Project("Test");
            _prj.Users.Add(new User("User 1"));

            _sprint = new Sprint(_prj, "Sprint 1");
            _prj.Sprints.Add(_sprint);
        }

        [TestMethod]
        public void AddingSprintGoals()
        {
            _sprint.Goals.Add(new SprintGoal("Goal 1", "Description 1"));
            _sprint.Goals.Add(new SprintGoal("Goal 2", "Description 2"));

            Assert.AreEqual(_sprint.Goals.Count, 2);
            Assert.AreEqual(_sprint.Goals[1].Name, "Goal 2");
            Assert.AreEqual(_sprint.Goals[1].Description, "Description 2");
        }

        [TestMethod]
        public void StartSprint()
        {
            _prj.Users[0].DaysOff.Add(new DateTime(2010, 6, 30), "test");
            _prj.Users[0].AvailableHours = 8;

            _sprint.StartSprint();
            _sprint.StartDate = new DateTime(2010, 6, 30);
            _sprint.EndDate = new DateTime(2010, 8, 5);

            _sprint.Availability[0].CalculatingAvailabilty();

            Assert.AreEqual(_sprint.Availability[0].User.Name, "User 1");
            Assert.AreEqual(_sprint.Availability[0].TotalDays, 27);
            Assert.AreEqual(_sprint.Availability[0].DaysOff, 1);
            Assert.AreEqual(_sprint.Availability[0].ActualDays, 26);
            Assert.AreEqual(_sprint.Availability[0].TotalHours, 208);
        }
    }
}
